// Array.map() 

Array.prototype.MyMap = function(fn) {
    if (typeof fn !== 'function') return [];

    let res = [];
    for (let i = 0; i < this.length; i++) {
        res.push(fn(this[i]));
    };

    return res;
};


console.log([1,2,3].MyMap(item => item * 2)); // [ 2, 4, 6 ]
